﻿using System;
using System.Text;

namespace GeneralMethodClass.Text
{
    /// <summary>
    /// 值不能为空异常
    /// </summary>
    public class ValueIsNullOrEmptyException : Exception
    {
        private const string FormatString = "{0}不能为空。";
        private string _name;

        public ValueIsNullOrEmptyException() : this("值") { }

        /// <summary>
        /// 初始化值不能为空异常
        /// </summary>
        /// <param name="name">导致该异常的值的名称</param>
        public ValueIsNullOrEmptyException(string name)
            : base(string.Format(FormatString, name))
        {
            _name = name;
        }

        public ValueIsNullOrEmptyException(string message, Exception innerException) : base(message, innerException) { }

        /// <summary>
        /// 获取导致该异常的值的名称
        /// </summary>
        public string Name { get { return _name; } }
    }
}
